<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>props的基本使用</title>
</head>
<body>
  <div id="test"></div>
  <div id="test1"></div>
  <div id="test2"></div>

  <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
  <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

  <script type="text/babel">
    // 创建组件
    class Person extends React.Component {
      render () {
        // render里面的this指向Person的实例对象，而实例对象上有一个属性props，可以用他来给组件传值
        const { name, sex, age } = this.props
        return (
          <ul>
            <li>姓名: { name }</li>  
            <li>性别: { sex }</li>  
            <li>年龄: { age }</li>  
          </ul>
        )
      }
    }
    // 此处直接在组件上定义要传的值，就可以在props中拿到
    ReactDOM.render(<Person name="tom" sex="girl" age="18" />, document.getElementById('test'))
    ReactDOM.render(<Person name="tom1" sex="boy" age="19" />, document.getElementById('test1'))
    ReactDOM.render(<Person name="tom2" sex="girl" age="20" />, document.getElementById('test2'))
  </script>
</body>
</html>